package com.zking.ssm.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zking.ssm.sys.mapper.HotelMemberMapper;
import com.zking.ssm.sys.model.HotelMember;
import com.zking.ssm.sys.model.HotelSellerEmployee;
import com.zking.ssm.sys.service.IHotelMemberService;
import com.zking.ssm.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotelMemberServiceImpl implements IHotelMemberService {

    @Autowired
    private HotelMemberMapper hotelMemberMapper;


    @Override
    public int deleteByPrimaryKey(Integer id) {
        return hotelMemberMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(HotelMember record) {
        return hotelMemberMapper.insert(record);
    }

    @Override
    public int insertSelective(HotelMember record) {
        return hotelMemberMapper.insertSelective(record);
    }

    @Override
    public HotelMember selectByPrimaryKey(Integer id) {
        return hotelMemberMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(HotelMember record) {
        return hotelMemberMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(HotelMember record) {
        return hotelMemberMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<HotelMember> list(HotelMember hotelMember, PageBean pageBean) {
        if (null != pageBean && 0 != pageBean.getRows()) {
            PageHelper.startPage(pageBean.getPage(), pageBean.getRows());
        }
        List<HotelMember> list = hotelMemberMapper.list(hotelMember);
        if (null != pageBean && 0 != pageBean.getRows()) {
            PageInfo pageInfo = new PageInfo(list);
            pageBean.setTotal(pageInfo.getTotal() + "");
        }
        return list;
    }
}
